home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / ease-3.5 / utils / build-new-aliases next >
Encoding:
Text File  |  1991-02-26  |  1.2 KB  |  57 lines

  1. #!/bin/csh -f
  2. # build-new-aliases
  3. # Bruce Barnett
  4. #
  5. # this script makes a new alias file
  6. #
  7. # first it has to shutdown sendmail
  8. # But do it nicely, using kill -15 at first.
  9.  
  10. # how many sendmail processes are running?
  11. set j = (`ps ax |grep sendmail|grep -v grep`);
  12.  
  13. set loopcount = 0
  14. if ( $#j > 0 ) then
  15.  
  16. loop:
  17. @    loopcount++
  18.     # wait 30 * 30 seconds for all of the sendmail processes to quit
  19.     if ( $loopcount > 30 ) then
  20.         echo ERROR - can not kill sendmail
  21.         goto problem
  22.     endif
  23.     kill -15 $j[1]
  24.     sleep 30
  25.     set j = (`ps ax |grep sendmail|grep -v grep`);        
  26.     if ( $#j > 0 ) then
  27.         goto loop
  28.     endif
  29. endif
  30. goto good
  31. problem:
  32. # could not kill sendmail - try something drastic
  33.     echo `date` kill sendmail >>/usr/spool/adm/build-new-aliases.log
  34.     kill -9 $j[1]
  35. good:
  36. set frozen = 0
  37. if ( -f /etc/sendmail.fc )  then
  38.     set frozen = 1
  39.     /bin/cp /dev/null /etc/sendmail.fc
  40. endif
  41. # clean up any lock files
  42. touch /usr/spool/mqueue/lf0
  43. /bin/rm -f /usr/spool/mqueue/lf*
  44.  
  45. # see the documentation about the 'a' option of sendmail
  46. # or the "D" option
  47. #/usr/lib/newaliases
  48. # rebuild aliases
  49. /usr/lib/sendmail -bi
  50.  
  51. if ( $frozen > 0 ) then
  52.     /usr/lib/sendmail -bz
  53. endif
  54.  
  55. # restart the daemon with 30 minutes between cycles
  56. /usr/lib/sendmail -bd -q30m -om
  57.